<template>
	<view>
	<view class="">
		<u-navbar back-text="重庆大学" :customBack="back" backIconName=" " :backTextStyle="backTextColor" backIconColor="#39CCCC" :background="background">
			<view class="search-wrap" @click="toSearch">
				<!-- 如果使用u-search组件，必须要给v-model绑定一个变量 -->
				<u-search height="56" :showAction="false" ></u-search>
			</view>
		</u-navbar>

		<view class="">
			<view class="toptem">
				<u-swiper :list="swiper" border-radius="0" :effect3d="true"></u-swiper>
			</view>
			<u-gap bgColor="#ededed" height="20"></u-gap>
		<view v-if="logined">
			<u-grid :col="3">
					<u-grid-item bg-color="#ffffff">
						<view class="grid-text" @click="shouji()">
							<image src="../../static/tianxie.png"  mode="aspectFill" class="u-image-container"></image>
							<div>信息收集</div>
							</view>
					</u-grid-item>
					<u-grid-item>
						
						<view class="grid-text" @click="news">
							<image src="../../static/zixun.png"  mode="aspectFill" class="u-image-container"></image>
							<div>校园资讯</div>
							</view>
					</u-grid-item>
					<u-grid-item>
						
						<view class="grid-text" @click="notice">
							<image src="../../static/notice.png"  mode="aspectFill" class="u-image-container"></image>
							<div>报到须知</div>
							</view>
					</u-grid-item>
					<u-grid-item>
						<view class="grid-text" @click="tobus">
							<image src="../../static/bus.png"  mode="aspectFill" class="u-image-container"></image>
							<div>校车时刻表</div>
							</view>
					</u-grid-item>
		
					<u-grid-item v-if="showlessIcon">
						<view class="grid-text" @click="more">
							<image src="../../static/more.png"  mode="aspectFill" class="u-image-container"></image>
							<div>更多</div>
							</view>
					</u-grid-item>
					<u-grid-item v-if="showmoreIcon">
						<view class="grid-text" @click="fankui()">
							<image src="../../static/suggest.png"  mode="aspectFill" class="u-image-container"></image>
							<div>意见反馈</div>
							</view>
					</u-grid-item>
					<u-grid-item v-if="showmoreIcon">
						<view class="grid-text" @click="less">
							<image src="../../static/less.png"  mode="aspectFill" class="u-image-container"></image>
							<div>收起</div>
							</view>
					</u-grid-item>
				</u-grid>
				</view>
				<view v-else>
					<u-grid :col="3">
							<u-grid-item bg-color="#ffffff">
								<view class="grid-text" @click="tosearchm">
									<image src="../../static/searchmes.png"  mode="aspectFill" class="u-image-container"></image>
									<div>学生信息查询</div>
									</view>
							</u-grid-item>
							<u-grid-item>
								
								<view class="grid-text" @click="tochangem">
									<image src="../../static/tianxie.png"  mode="aspectFill" class="u-image-container"></image>
									<div>学生信息修改</div>
									</view>
							</u-grid-item>
							<u-grid-item>
								
								<view class="grid-text" @click="toID">
									<image src="../../static/zhanghao.png"  mode="aspectFill" class="u-image-container"></image>
									<div>学生账号注册</div>
									</view>
							</u-grid-item>
							<u-grid-item>
								<view class="grid-text" @click="tosee1()">
									<image src="../../static/zixun.png"  mode="aspectFill" class="u-image-container"></image>
									<div>学生账号注销</div>
									</view>
							</u-grid-item>
							<u-grid-item>
								<view class="grid-text" @click="tosee()">
									<image src="../../static/fankui.png"  mode="aspectFill" class="u-image-container"></image>
									<div>查看反馈</div>
									</view>
							</u-grid-item>
							
						</u-grid>
				</view>
			<!-- list -->
			<list></list>
		</view>
		
		<u-back-top :scrollTop="scrollTop" :mode="modeTop" :bottom="bottomTop" :right="rightTop" :top="top" :icon="iconTop"
		 :custom-style="customStyle" :icon-style="iconStyleTop" :tips="tips">
		</u-back-top>
		
	</view>
	<view style="text-align: center;">
	
		<u @click="loadmore" style="color: #aa0000;">加载更多</u>
	</view>
	</view>
</template>

<script>
	import list from '@/components/list'
	export default {
		components:{list},
		data() {
			return {
				logined:true,
				showmoreIcon:false,
				showlessIcon:true,
				swiper: [{
						image: '/static/1.jpg',
						title: '昨夜星辰昨夜风，画楼西畔桂堂东'
					},
					{
						image: '/static/2.PNG',
						title: '身无彩凤双飞翼，心有灵犀一点通'
					},
					{
						image: '/static/3.jpg',
						title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
					}
				],
				background: {
					'background-image': 'linear-gradient(45deg, #2BC3C8, #84E7B9)'
				},
				backTextColor: {
					'color': '#ffffff'
				},
				// top
				scrollTop: 0,
				modeTop: 'circle',
				bottomTop: 200,
				rightTop: 40,
				top: 600,
				iconTop: 'arrow-up',
				iconStyleTop: {
					color: '#ffffff',
					fontSize: '30rpx'
				},
				customStyle: {
					backgroundColor: '#39CCCC',
					color: '#ffffff'
				},
				tips: '顶部',
			}
		},
		onLoad() {

		},
		onShow(){
			const va1=uni.getStorageSync('shu01')
			const shu=uni.getStorageSync('wen')
			if(shu=="1"&&va1=="12"){
				this.logined=true
			}else if(shu=="2"&&va1!="12"){
				this.logined=false
			}else{
				this.logined=true
			}
		},
		methods: {
			tosee1(){
				uni.navigateTo({
					url:'/pages/zhuxiao/zhuxiao'
				})
			},
			toID(){
				uni.navigateTo({
					url:'/pages/login/zhuce'
				})
			},
			tosee(){
				uni.navigateTo({
					url:'/pages/display_fank/display_fank'
				})
			},
			tochangem(){
				uni.navigateTo({
					url:'/pages/xiugai01/xiugai01'
				})
			},
			tosearchm(){
				uni.navigateTo({
					url:"/pages/chaxun_stu/chaxun_stu"
				})
			},
			fankui(){
				uni.navigateTo({
					url:"/pages/mine/feedback"
				})
			},
			shouji(){
				const va1=uni.getStorageSync('shu01')
				const shu=uni.getStorageSync('wen')
				if(shu==""||va1=="12"){
					this.$u.toast('请先登录账号再进行信息收集')
					return
				}
				uni.navigateTo({
					url:"/pages/collect/collect"
				})
			},
			toSearch(){
				this.$common.navigateTo('/pages/index/search')
			},
			back() { // 首页
				uni.navigateBack({
					delta: 2
				})
			},
			toDetail(){
				this.$common.navigateTo('/pages/index/detail')
			},
			// 回到顶部
			onPageScroll(e) {
				this.scrollTop = e.scrollTop;
			},
			loadmore(){
				uni.switchTab({
					url:'/pages/object/index',
					// fail: err => {
					//     console.error('Navigation failed:', err);
					//   }
				})
				// console.log("66")
			},
			tobus(){
				uni.navigateTo({
					url:'/pages/index/bustime'
				})
			},
			more(){
				this.showmoreIcon=true;
				this.showlessIcon=false;
			},
			less(){
				this.showlessIcon=true;
				this.showmoreIcon=false
			},
			notice(){
				uni.navigateTo({
					url:'/pages/index/freshman1'
				})
			},
			news(){
				uni.navigateTo({
					url:'/pages/object/objectList'
				})
			}
		}
	}
</script>

<style lang="scss">
	.search-wrap {
		margin: 0 30rpx 0 10rpx;
		flex: 1;
	}
	.grid-text {
		  display: flex;             /* 使用Flex布局 */
		    flex-direction: column;    /* 垂直方向布局 */
		    align-items: center;       /* 居中对齐 */
			font-size: 28rpx;
			margin-top: 4rpx;
			color: $u-type-info;
		}


	.u-body-item {
		font-size: 32rpx;
		color: #333;
		padding: 20rpx;
	}

	.u-body-item image {
		width: 180rpx;
		flex: 0 0 180rpx;
		height: 150rpx;
		border-radius: 6rpx;
		margin-right: 12rpx;
	}
	
	.height{
		height: 88rpx;
	}

	.toptem {
		padding: 20rpx 0;
	}
	.u-image-container {
	  flex: 0 0 auto; /* 让图片容器不占用多余的空间 */
	  width: 40rpx; /* 设置容器宽度，可以根据需要进行微调 */
	  height: 40rpx; /* 设置容器高度，保持和宽度相等 */
	}
</style>
